﻿using Microsoft.Extensions.Configuration;
using MiniFox.Components;
using MiniFox.Configurations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MiniFox.Platform.OAuth2.Configurations
{
    /// <summary>
    /// 
    /// </summary>
    [Section(ELEMENT_NAME)]
    public class AccessTokenConfiguration
    {
        internal const string ELEMENT_NAME = "minifox:oauth2:accessToken";

        const int ACCESS_TOKEN_EXPIRES = 7200;
        const int RENEW_TOKEN_EXPIRES = 36000;
        const int CACHE_DURATION = 3600;
        /// <summary>
        /// 
        /// </summary>
        public AccessTokenConfiguration()
        {
            this.AccessTokenExpires = ACCESS_TOKEN_EXPIRES;
            this.RenewTokenExpires = RENEW_TOKEN_EXPIRES;
            this.CacheDuration = CACHE_DURATION;
        }
        /// <summary>
        /// 令牌过期时长(秒),默认值7200
        /// </summary>
        [ConfigurationKeyName("accessTokenExpires")]
        public int AccessTokenExpires
        {
            get;
            set;
        }
        /// <summary>
        /// 刷新令牌过期时长(秒),默认值36000秒(10小时)
        /// </summary>
        [ConfigurationKeyName("renewTokenExpires")]
        public int RenewTokenExpires
        {
            get;
            set;
        }
        /// <summary>
        /// 令牌过期时长(秒),默认值3600
        /// </summary>
        [ConfigurationKeyName("cacheDuration")]
        public int CacheDuration
        {
            get;
            set;
        }
    }
}
